Skip to content

Conversation

@angrykoala
Copy link
Member

@angrykoala angrykoala commented Dec 10, 2025

Description

Support for using @cypher directives in relationship properties

The following will not be supported:

  • Aggregate by @cypher fields (both, in edge and node)

Example:

type Movie @node {
    title: String!
    actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
}

type Actor @node {
    name: String!
    actedIn: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT, properties: "ActedIn")
}

type ActedIn @relationshipProperties {
    screenTimeHours: Float
        @cypher(
            statement: """
            RETURN this.screenTimeMinutes / 60 AS c
            """
            columnName: "c"
        )
    screenTimeMinutes: Int
}

@angrykoala angrykoala linked an issue Dec 10, 2025 that may be closed by this pull request
@changeset-bot
Copy link

changeset-bot bot commented Dec 10, 2025

🦋 Changeset detected

Latest commit: f49033b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@neo4j/graphql Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@neo4j-team-graphql
Copy link
Collaborator

neo4j-team-graphql commented Dec 18, 2025

Performance Report

No Performance Changes

Show Full Table
name dbHits old dbHits time (ms) old time (ms) maxRows
aggregations.TopLevelAggregateWithMultipleFields 7936 7936 58 80 1134
aggregations.NestedAggregation 15407 15407 61 96 2174
aggregations.AggregationWithWhere 10833 10833 46 66 2174
aggregations.AggregationWhereWithinNestedRelationships 20097917 20097917 1941 2110 2008534
aggregations.AggregationWhereWithinNestedConnections 20097917 20097917 1914 1963 2008534
aggregations.InterfacesAggregations 8324 8324 92 138 2080
aggregations.InterfacesAggregationsWithTwoFields 13526 13526 127 156 2080
connections.Connection 12951 12951 58 71 2174
connections.NestedConnection 37705 37705 152 142 4516
connections.totalCount 1 1 29 138 1
cypher-directive-mutation.TopLevelMutationDirective 1135 1135 42 35 1134
cypher-directive.TopLevelSortWithCypher 12961 12961 41 57 2174
cypher-directive.TopLevelConnectionSortWithCypher 12961 12961 58 71 2174
cypher-directive.TopLevelSortWithCypherWithNested 13096 13096 63 70 2174
cypher-directive.TopLevelConnectionSortWithCypherWithNested 13096 13096 90 112 2174
cypher-directive.TopLevelSortWithExpensiveCypher 13725 13725 96 163 2174
cypher-directive.TopLevelConnectionSortWithExpensiveCypher 13266 13266 95 139 2174
fulltext.Fulltext 80 80 42 50 16
fulltext.FulltextWithNestedQuery 516 516 61 83 84
1262.NestedConnectionWhere 8703 8703 58 69 2174
187.QueryWhere 8564 8564 38 42 2154
2871.NestedRelationshipFilter 19632 19632 55 65 4395
batch-create.BatchCreate 3600 3600 87 98 600
connect.createAndConnect 4410 4410 52 74 1134
create.SimpleMutation 6 6 30 36 1
delete.SimpleDelete 19401 19401 625 640 1040
delete.NestedDeleteInUpdate 14688 14688 99 159 1179
update.NestedUpdate 10129 10129 66 81 2002
query.SimpleQuery 3121 3121 21 23 1040
query.SimpleQueryWithRelationship 15031 15031 46 52 2174
query.SimpleQueryWithNestedWhere 8713 8713 49 67 2154
query.Nested 3988 3988 78 94 1040
query.OrFilterOnRelationships 36733 36511 171 198 1956
query.OrFilterOnRelationshipsAndNested 26722 26546 199 231 1956
query.QueryWithNestedIn 14201 14198 55 65 1867
query.DeeplyNestedConnectionWhere 8702 8702 74 105 2174
query.DeeplyNestedWithRelationshipFilters 17357 17357 134 175 1552
query.NestedWithRelationshipSingleFilters 3808 3808 194 224 1134
sorting.SortMultipleTypes 3436 3436 75 87 1040
sorting.SortMultipleTypesWithCypherWithCypher 13321 13321 97 107 2174
sorting.SortOnNestedFields 12951 12951 52 53 2174
sorting.SortDeeplyNestedFields 39785 39785 98 115 4516
sorting.ConnectionWithSort 3271 3271 67 76 1040
unions.SimpleUnionQuery 321 321 54 61 35
unions.SimpleUnionQueryWithMissingFields 293 293 61 64 35
unions.NestedUnion 309975 309975 250 273 33033
unions.NestedUnionWithMissingFields 283949 283949 247 254 33033

Old Schema Generation: 21.542s
Schema Generation: 21.586s
Old Subgraph Schema Generation: 25.490s
Subgraph Schema Generation: 25.367s

@angrykoala angrykoala marked this pull request as ready for review December 18, 2025 12:23
@angrykoala angrykoala changed the title WIP support for cypher directive in relationship properties Support for cypher directive in relationship properties Jan 5, 2026
Copy link
Contributor

@MacondoExpress MacondoExpress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left some comments,
can you also verifies that the https://neo4j.com/docs/graphql/current/directives/schema-configuration/field-configuration/#_selectable @selectable. @filterable, @settable are working as expected?

"@neo4j/graphql": patch
---

Add support for `@cypher` directive in relationship properties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small snippet such as:

type ActedIn @relationshipProperties {
    screenTimeHours: Float
        @cypher(
            statement: """
            RETURN this.screenTimeMinutes / 60 AS c
            """
            columnName: "c"
        )
    screenTimeMinutes: Int
}

Could give a better idea to the reader about what this changes is about!

},
{}
);
const cypherSortFieldsEdgeFlagMap = sortEdgeFields.reduce<Record<string, boolean>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could avoid having duplicate code in this file between Node and Edge fields, to give more visibility (if needed) when these have to behave differently

});
});

test("top-level union", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong test title

@angrykoala
Copy link
Member Author

LGTM, left some comments, can you also verifies that the https://neo4j.com/docs/graphql/current/directives/schema-configuration/field-configuration/#_selectable @selectable. @filterable, @settable are working as expected?

Added schema tests for selectable and selectable.

Settable is no-op on cypher directives

@angrykoala angrykoala force-pushed the 5623-cypher-on-relationship-fields branch from 4d5981b to f49033b Compare January 6, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@cypher on relationship fields

4 participants